package com.biz.hunter.dao;

import org.springframework.stereotype.Repository;

import com.biz.hunter.db.entity.OrderResume;
import com.biz.hunter.dbutil.BaseDAO;

@Repository
public class OrderResumeDAO {
	private static final String SQL_GET_ID = "select * from tb_order_resume where id = ?";
	private static final String SQL_SAVE = "INSERT INTO tb_order_resume(openid, orderId,employeeId,hunterId,ordescId,file,remark,createtime,updatetime) VALUES(?,?,?,?,?,?,?,?,?)";
	private static final String SQL_GET_ORDERID="select * from tb_order_resume where orderId=?";
	private static final String SQL_UPDATE="update tb_order_resume set fileupd=?,updatetime=? where id=?";
	
	public OrderResume getById(long Id) {
		return BaseDAO.queryForObject(OrderResume.class, SQL_GET_ID, Id);
	}

	public OrderResume getByOrderId(long orderId){
		return BaseDAO.queryForObject(OrderResume.class, SQL_GET_ORDERID, orderId);
	}
	
	public long saveOrderResume(OrderResume resume) {
		if (resume == null) {
			return -1;
		}

		Long result = BaseDAO.save(SQL_SAVE, resume.getOpenid(), resume.getOrderId(),
				resume.getEmployeeId(),resume.getHunterId(),resume.getOrdescId(),
				resume.getFile(),resume.getRemark(),resume.getCreatetime(),resume.getUpdatetime());
		if (result != null) {
			return result.longValue();
		}
		return -1;
	}
	
	public long updOrderResume(String fileupd,String time,long id){
		Long result = BaseDAO.save(SQL_UPDATE,fileupd,time,id);
		if (result != null) {
			return result.longValue();
		}
		return -1;
	}


}
